import React from 'react'
import { useList } from '../../context/ListProvider';
import { DEL_ITEM } from '../../reducers/list-reducer';

const Item = ({item}) => {
    const {dispatch} = useList();
    const del = () => dispatch({type: DEL_ITEM,id: item.id});
    return (
        <li key={item.id}>
            {item.title}
            <button onClick={del}>删除</button>
        </li>
    )
}

export default Item